<!DOCTYPE html>
<script src="../../../resources/js-test.js"></script>
<iframe id="quirks" src="resources/frameset-quirks.html"></iframe><br>
<script>
  var iframeQuirks;

  shouldBe("document.scrollingElement", "document.documentElement");

  var bodyElement;

  function verifyTest() {
    description('Test for scrollTop/Left values of document.body and document.documentElement in documents where the body is a frameset element');

    iframeQuirks = document.getElementById("quirks");

    shouldBe("iframeQuirks.contentDocument.body", "iframeQuirks.contentDocument.querySelector('frameset')");
    shouldBeNull("iframeQuirks.contentDocument.scrollingElement");
    shouldBe("iframeQuirks.contentDocument.documentElement.scrollTop", "0");
    shouldBe("iframeQuirks.contentDocument.documentElement.scrollLeft", "0");
    shouldBe("iframeQuirks.contentDocument.body.scrollTop", "0");
    shouldBe("iframeQuirks.contentDocument.body.scrollLeft", "0");
    shouldBe("iframeQuirks.contentWindow.pageYOffset", "500");
    shouldBe("iframeQuirks.contentWindow.pageXOffset", "200");
    debug('');

    debug('Add extra body element');
    bodyElement = iframeQuirks.contentDocument.createElement("BODY");
    iframeQuirks.contentDocument.documentElement.appendChild(bodyElement);
    shouldBe("iframeQuirks.contentDocument.body", "iframeQuirks.contentDocument.querySelector('frameset')");
    shouldBe("iframeQuirks.contentDocument.scrollingElement", "bodyElement");
    shouldBe("iframeQuirks.contentDocument.documentElement.scrollTop", "0");
    shouldBe("iframeQuirks.contentDocument.documentElement.scrollLeft", "0");
    shouldBe("iframeQuirks.contentDocument.body.scrollTop", "0");
    shouldBe("iframeQuirks.contentDocument.body.scrollLeft", "0");
    shouldBe("iframeQuirks.contentWindow.pageYOffset", "500");
    shouldBe("iframeQuirks.contentWindow.pageXOffset", "200");
    shouldBe("iframeQuirks.contentDocument.scrollingElement.scrollTop", "500");
    shouldBe("iframeQuirks.contentDocument.scrollingElement.scrollLeft", "200");
    
    finishJSTest();
  }
  var jsTestIsAsync = true;
</script>
